
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
        <meta name="author" content="order by itying"/>
		<title>会员登录</title>
		<link rel="stylesheet" href="/static/itying/css/login.css" />
		<script src="/static/itying/js/jquery-1.10.1.js"></script>		
	</head>
	<body class="login_page">
		<!-- login -->
		<div class="top center">
			<div class="logo center">
				<a href="/" target="_blank"><img src="/static/itying/image/mistore_logo.png" alt=""></a>
			</div>
		</div>
		
		<div class="login">
			<div class="login_center">
				<div class="login_top">
					<div class="left fl">会员登录</div>
					<div class="right fr">您还不是我们的会员？<a href="/pass/registerStep1" target="_self">立即注册</a></div>
					<div class="clear"></div>
					<div class="xian center"></div>
				</div>

				<div class="login_main center">
					<input type="hidden" id="prevPage" value="{{.prevPage}}">
					<div class="username">手机号：<input class="shurukuang" id="phone" type="text" name="phone" placeholder="请输入你的用户名"/></div>
					<div class="username">密　码：<input class="shurukuang" id="password"  type="password" name="password" placeholder="请输入你的密码"/></div>
					<div class="username">
						<div class="left fl">验证码：<input class="yanzhengma" id="photo_code" type="text" name="photo_code" placeholder="请输入验证码"/></div>
						<div class="right fl">
							{{create_captcha}}
						</div>
						<div class="clear"></div>
					</div>
				</div>
				<div class="error">
					
				</div>
				<div class="login_submit">
					<input class="submit" type="button" id="doLogin" value="立即登录" >
				</div>
				
			</div>
		</div>
		
		<footer>
			<div class="copyright">简体 | 繁体 | English | 常见问题</div>
			<div class="copyright">小米公司版权所有-京ICP备10046444-<img src="/public/default/image/ghs.png" alt="">京公网安备11010802020134号-京ICP证110507号</div>

		</footer>

		<script>				
			$(function(){
				$("#doLogin").click(function(e){
					var phone=$('#phone').val();
					var password= $('#password').val();			
					var photo_code = $('#photo_code').val();
					var photoCodeId = $("input[name='captcha_id']").val();
					var prevPage = $("#prevPage").val();

					var reg =/^[\d]{11}$/;
					if(!reg.test(phone)){
						alert('手机号输入错误');
						return false;
					}
					if(password.length<6){
						alert('密码长度不合法');
						return false;
					}

					if(photo_code.length<4){
						alert('验证码长度不合法');
						return false;
					}
					//ajax请求	 														
					$.post('/pass/doLogin',{phone:phone,password:password,photo_code:photo_code,photoCodeId:photoCodeId},function(response){							
						console.log(response);
						if(response.success==true){
							if (prevPage){
								location.href=prevPage;
							}else{
								location.href="/";
							}
							
						}else{
							//改变验证码											
							$(".error").html("Error：" + response.msg + ",请重新输入!")
							//改变验证码
							var captchaImgSrc = $(".captcha-img").attr("src")
							$(".photo_code").val("")
							$(".captcha-img").attr("src", captchaImgSrc + "?reload=" + (new Date()).getTime())
						}					
					})
				})

			})
		</script>
		
	</body>
</html>